home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
5
/
DINKDEMO
/
DC_SCRIB
/
DSCRIBBL.C
next >
Wrap
Text File
|
1992-05-17
|
2KB
|
81 lines
// This is the class definition of DScribbleWind
#include "DScribbleWind.h"
#include "DScribbleDoc.h"
Boolean DScribbleWind :: Init(DDocument *doc, Boolean hasColorWindows)
{
Boolean inheritedSuccess;
PicHandle thePict;
thePict = ((DScribbleDoc *) doc)->fPict;
fPenSize = 1;
fPenPat = patBlack;
inheritedSuccess = inherited :: Init(doc, hasColorWindows);
if(thePict != NULL)
{
fVMin = 0;
fVMax = (**thePict).picFrame.bottom - (**thePict).picFrame.top;
fHMin = 0;
fHMax = (**thePict).picFrame.right - (**thePict).picFrame.left;
}
Draw (&fWindowPtr->portRect);
return (inheritedSuccess);
}// end of init function
void DScribbleWind :: DoContent(EventRecord* theEvent)
{
Rect contents;
Point newPoint;
PicHandle thePict;
FocusOnWindow();
GlobalToLocal(&theEvent->where);
GetContentRect(&contents);
if(PtInRect(theEvent->where, &contents))
{
PenSize(fPenSize, fPenSize);
if(fPenPat == patBlack)
PenPat(black);
if(fPenPat == patGray)
PenPat(gray);
if(fPenPat == patWhite)
PenPat(white);
FocusOnContent();
GetMouse( &newPoint);
MoveTo(newPoint.h, newPoint.v);
do
{
GetMouse( &newPoint);
LineTo(newPoint.h, newPoint.v);
} while(StillDown());
fDoc->fNeedToSave = TRUE;
thePict = ((DScribbleDoc *) fDoc)->fPict;
if( thePict != NULL)
KillPicture( thePict);
thePict = OpenPicture(&fWindowPtr->portRect);
CopyBits(&fWindowPtr->portBits, &fWindowPtr->portBits,
&fWindowPtr->portRect, &fWindowPtr->portRect, srcCopy, NULL);
ClosePicture();
((DScribbleDoc *) fDoc)->fPict = thePict;
}// end if in content rect
else
ScrollClick(theEvent);
}// end of DoContent function
void DScribbleWind :: Draw(Rect *r)
{
if(((DScribbleDoc *) fDoc)->fPict != NULL)
DrawPicture(((DScribbleDoc *) fDoc)->fPict, &( (*(((DScribbleDoc *) fDoc)->fPict))->picFrame ) );
}